ConversationIndex Property (Message
Object)
The ConversationIndex
property specifies the index to the conversation thread of the message.
Read/write.
Syntax
objMessage.ConversationIndex
Data Type
String
Remarks
The ConversationIndex
property is a string that represents a hexadecimal number. Valid characters
within the string include the numbers 0 through 9 and the letters A through F
(uppercase or lowercase).
A
conversation is a group of related messages that have the same ConversationTopic
property value. In a discussion application, for example, users can save original
messages and response messages. Messages can be tagged with the ConversationIndex
property so that users can group messages by conversation.
You can use
your own convention to decide how this index should be used. However, it is
recommended that you adopt the same convention that is used by the Microsoft
Exchange Client message viewer, so that you can use that viewer s user
interface to show the relationships between messages in a conversation.
By
convention, Microsoft Exchange Server uses ConversationIndex values that
represent concatenated time stamp values. The first time stamp in the string
represents the original message. When a new message represents a reply to a
conversation message, it copies the ConversationIndex string of the
message it is replying to, and then appends a time stamp value to the end of
the string. The new string value is used as the ConversationIndex value
of the new message.
When you use
this convention, you can see relationships among messages when you sort the
messages by ConversationIndex values.
The ConversationIndex
property corresponds to the MAPI property PR_CONVERSATION_INDEX.
Example
The following
example takes advantage of an OLE function that is available on computers that
run the OLE Messaging Library. The CoCreateGUID function returns a value
that consists of a time stamp and a machine identifier; this sample code saves
the part that contains the time stamp.
' declarations section
Type GUID '
global unique identifier; contains a time stamp
Guid1 As
Long
Guid2 As
Long
Guid3 As
Long
Guid4 As Long
End Type
' function appears in OLE32.DLL on Windows/NT and
Windows 95
Declare Function CoCreateGuid Lib
"COMPOBJ.DLL" (pGuid As GUID) As Long
Global Const S_OK = 0 ' return value from CoCreateGuid
Function Util_GetEightByteTimeStamp() As String
Dim lResult As Long
Dim lGuid As GUID
' Exchange
conversation is a unique 8-byte value
' Exchange
client viewer sorts by concatenated properties
On Error
GoTo error_olemsg
lResult =
CoCreateGuid(lGuid)
If lResult
= S_OK Then
Util_GetEightByteTimeStamp
= _
Hex$(lGuid.Guid1) & Hex$(lGuid.Guid2)
Else
Util_GetEightByteTimeStamp = "00000000" ' zeroes
End If
Exit
Function
error_olemsg:
MsgBox
"Error " & Str(Err) & ": " & Error$(Err)
Util_GetEightByteTimeStamp
= "00000000"
Exit
Function
End Function
Function Util_NewConversation()
Dim i As Integer
Dim objNewMsg As Object ' new message object
Dim strNewIndex As String ' value for ConversationIndex
' ... error handling...
Set
objNewMsg = objSession.Outbox.Messages.Add
' ... error handling...
With
objNewMsg
.Subject = "used space vehicle wanted"
.ConversationTopic = .Subject
.ConversationIndex = Util_GetEightByteTimeStamp() ' utility
.Text
= "Wanted: Apollo or Mercury spacecraft with low mileage."
' or you could pick the public folder from the
address book
Set
objOneRecip = .Recipients.Add(Name:="Car Ads", Type:=mapiTo)
If
objOneRecip Is Nothing Then
MsgBox "Unable to create the public folder recipient"
Exit Function
End If
.Recipients.Resolve
.Update
.Send
showDialog:=False
End With
End Function
A subsequent
reply to a message should copy the ConversationTopic property and append
its own time stamp to the original message s time stamp, as shown in the
following example:
Function Util_ReplyToConversation()
Dim objPublicFolder As Object
Dim i As Integer
Dim objOriginalMsg As Object ' original message in
public folder
Dim objNewMsg As Object ' new message object for reply
Dim strPublicFolderID As String ' ID for public
folder
Set
objNewMsg = objSession.Outbox.Messages.Add
' error
checking...obtain objOriginalMsg and check that it is valid
With objNewMsg
.Text
= "How about a slightly used Gemini?" ' new text
.Subject = objOriginalMsg.Subject
' copy original properties
.ConversationTopic = objOriginalMsg.ConversationTopic
'
append time stamp; compatible with Microsoft Exchange client
.ConversationIndex = objOriginalMsg.ConversationIndex & _
Util_GetEightByteTimeStamp() ' append new
'
message was sent to a public folder so can copy recipient
Set
objOneRecip = .Recipients.Add( _
Name:=objOriginalMsg.Recipients.Item(1).Name, _
Type:=mapiTo)
'
...more error handling
.Recipients.Resolve
.Update
.Send
showDialog:=False
End With
' ... error handling
End Function
See Also
Conversation Property, ConversationTopic
Property (Message Object)